//
//  ZYXTgCell.m
//  OCUIBasis
//  一个食品的UITableViewCell
//

#import "ZYXTgCell.h"
#import "ZYXTg.h"


@interface ZYXTgCell()

@property (weak, nonatomic) IBOutlet UIImageView    *iconView;
@property (weak, nonatomic) IBOutlet UILabel        *titleView;
@property (weak, nonatomic) IBOutlet UILabel        *priceView;
@property (weak, nonatomic) IBOutlet UILabel        *buyCountView;

@end

@implementation ZYXTgCell

+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *ID = @"tg";
    ZYXTgCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        
        // 从xib中加载cell
        cell = [[[NSBundle mainBundle] loadNibNamed:@"ZYXTgCell" owner:nil options:nil] lastObject];
    }
    return cell;
}

- (void)setTg:(ZYXTg *)tg
{
    _tg = tg;
    
    self.iconView.image     = [UIImage imageNamed:tg.icon];
    self.titleView.text     = tg.title;
    self.priceView.text     = [NSString stringWithFormat:@"￥%@", tg.price];
    self.buyCountView.text  = [NSString stringWithFormat:@"%@人已购买", tg.buyCount];
}

@end
